<template>
    <div>
        <h2>deletebyid</h2>
        <hr>
        <ul>
            <li v-for="(item,index) in datalist" :key="index">
                {{index+1}}、{{item}}
            </li>
        </ul>
        <hr>
        <select name="1" id="s1" style="width:200px;" v-model="selectIndex">
            <option v-for="(item,index) in datalist" :key="index" :value="index">{{index+1}}</option>
        </select>
        <button @click="removeItem">点击删除指定项目</button>

    </div>
</template>

<script>
export default {
    data(){
        return{
            datalist:[1,2,3,4,5,6,7,8,9],
            selectIndex:0
        }
    },
    methods:{
        removeItem(){
            this.$message("当前选中的项目下标为："+this.selectIndex)
            this.datalist.splice(this.selectIndex,1)
            this.$message("删除成功")

        }
    }
}
</script>